package com.mybatisplus.mapper;

import com.mybatisplus.entity.Teacher;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * Auto created By IntelliJ IDEA
 *
 * @author : gzrong
 * @Date : 2023/5/713:04
 */
@Repository
public interface TeacherMapper {
    @Select("select * from teacher")
    Teacher getTeacherByID(String id);

    @Select("select name from teacher where teacherID = #{stuid}")
    String getTeacherNameByTeacherID(@Param("stuid") String stuid);

    @Select("SELECT EXISTS(SELECT 1 FROM teacher WHERE teacherID=#{stuid} AND password = #{password} )")
    boolean checkUserExists(@Param("stuid") String stuid, @Param("password") String password);

    @Update("UPDATE teacher set password=#{password} where teacherID=#{stuid}")
    void updatePasswordByStuid(@Param("stuid") String stuid, @Param("password") String password);
}
